import request from '@/utils/request'

// 查询角色人才库字段权限列表
export function listPermission(query) {
  return request({
    url: '/talent/permission/list',
    method: 'get',
    params: query
  })
}

// 查询角色人才库字段权限详细
export function getPermission(id) {
  return request({
    url: '/talent/permission/' + id,
    method: 'get'
  })
}

// 根据角色ID和表名查询权限列表
export function getPermissionsByRoleAndTable(roleId, tableName) {
  return request({
    url: '/talent/permission/role/' + roleId + '/table/' + tableName,
    method: 'get'
  })
}

// 新增角色人才库字段权限
export function addPermission(data) {
  return request({
    url: '/talent/permission',
    method: 'post',
    data: data
  })
}

// 修改角色人才库字段权限
export function updatePermission(data) {
  return request({
    url: '/talent/permission',
    method: 'put',
    data: data
  })
}

// 删除角色人才库字段权限
export function delPermission(ids) {
  return request({
    url: '/talent/permission/' + ids,
    method: 'delete'
  })
}

// 批量保存角色权限
export function batchSavePermissions(roleId, tableName, data) {
  return request({
    url: '/talent/permission/batch/' + roleId + '/' + tableName,
    method: 'post',
    data: data
  })
}

